﻿// Decompiled with JetBrains decompiler
// Type: TaleWorlds.CampaignSystem.LogEntries.ArmyCreationLogEntry
// Assembly: TaleWorlds.CampaignSystem, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: E85F8C15-4DF6-4E9C-A58A-29177E40D07A
// Assembly location: D:\steam\steamapps\common\Mount & Blade II Bannerlord\bin\Win64_Shipping_Client\TaleWorlds.CampaignSystem.dll

using Helpers;
using System.Collections.Generic;
using TaleWorlds.Localization;
using TaleWorlds.ObjectSystem;
using TaleWorlds.SaveSystem;

#nullable disable
namespace TaleWorlds.CampaignSystem.LogEntries
{
  public class ArmyCreationLogEntry : LogEntry, IEncyclopediaLog, IWarLog
  {
    [SaveableField(20)]
    private readonly CharacterObject _armyLeader;

    internal static void AutoGeneratedStaticCollectObjectsArmyCreationLogEntry(
      object o,
      List<object> collectedObjects)
    {
      ((LogEntry) o).AutoGeneratedInstanceCollectObjects(collectedObjects);
    }

    protected override void AutoGeneratedInstanceCollectObjects(List<object> collectedObjects)
    {
      base.AutoGeneratedInstanceCollectObjects(collectedObjects);
      collectedObjects.Add((object) this._armyLeader);
    }

    internal static object AutoGeneratedGetMemberValue_armyLeader(object o)
    {
      return (object) ((ArmyCreationLogEntry) o)._armyLeader;
    }

    public override CampaignTime KeepInHistoryTime => CampaignTime.Weeks(1f);

    public ArmyCreationLogEntry(Army army)
    {
      this._armyLeader = army.LeaderParty.LeaderHero.CharacterObject;
    }

    public override string ToString() => this.GetEncyclopediaText().ToString();

    public bool IsRelatedToWar(StanceLink stance, out IFaction effector, out IFaction effected)
    {
      IFaction faction1 = stance.Faction1;
      IFaction faction2 = stance.Faction2;
      effector = this._armyLeader.HeroObject.MapFaction;
      effected = (IFaction) null;
      return this._armyLeader.HeroObject.MapFaction == faction1 || this._armyLeader.HeroObject.MapFaction == faction2;
    }

    public bool IsVisibleInEncyclopediaPageOf<T>(T obj) where T : MBObjectBase
    {
      return (object) obj == this._armyLeader.HeroObject;
    }

    public TextObject GetEncyclopediaText()
    {
      TextObject parent = new TextObject("{=aXhPvVud}{HERO.LINK} created an army.");
      StringHelpers.SetCharacterProperties("HERO", this._armyLeader, parent);
      return parent;
    }
  }
}
